home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Dialectic 1.2 / source / Dialectic ƒ / Dialectic code / dialectic dispatch.c next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  5.9 KB  |  221 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        dialectic dispatch.c
  4.  
  5. Purpose:    This module handles dispatching to the different conversion
  6.             routines.
  7.  
  8.  
  9. Dialectic -=- dialect text conversion extraordinare
  10. Copyright ©1994, Mark Pilgrim
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "dialectic dispatch.h"
  30. #include "dialectic utilities.h"
  31. #include "program globals.h"
  32.  
  33. unsigned char    gWhichDialect;
  34. unsigned long    gInputOffset;
  35. unsigned long    gOutputOffset;
  36. Ptr                gInputBuffer;
  37. Ptr                gOutputBuffer;
  38. Boolean            gInputNeedsUpdate;
  39. Boolean            gOutputNeedsUpdate;
  40. unsigned long    gAbsoluteOffset;
  41. unsigned long    gInputLength;
  42. Boolean            gInWord;
  43. Boolean            gSeenI;
  44. Boolean            gSeenBackslash;
  45. int                gCurlyLevel;
  46. Boolean            gDoingRTF;
  47.  
  48. void ConvertDispatch(void)
  49. {
  50.     unsigned char    oneChar;
  51.     
  52.     if (gUseRTF)
  53.     {
  54.         oneChar=ThisChar();
  55.         if ((oneChar=='}') && (gCurlyLevel>0))
  56.         {
  57.             gCurlyLevel--;
  58.             if (gCurlyLevel==0)
  59.                 gDoingRTF=FALSE;
  60.         }
  61.         else if (oneChar=='{')
  62.         {
  63.             gCurlyLevel++;
  64.             if ((NextChar(1)==0x5c) && (NextChar(2)=='r') && (NextChar(3)=='t') &&
  65.                 (NextChar(4)=='f'))
  66.                 gDoingRTF=TRUE;
  67.         }
  68.         
  69.         if (gDoingRTF)
  70.         {
  71.             if (oneChar==0x5c)
  72.                 gSeenBackslash=TRUE;
  73.             
  74.             if ((gCurlyLevel>2) || (gSeenBackslash))
  75.             {
  76.                 StoreChar(oneChar);
  77.                 InputPlus(1);
  78.                 if ((oneChar==' ') || (IsNumeric(oneChar)))
  79.                     gSeenBackslash=FALSE;
  80.                 return;
  81.             }
  82.         }
  83.     }
  84.     
  85.     switch (gWhichDialect)
  86.     {
  87.         case kChef:        ConvertChef();        break;
  88.         case kFudd:        ConvertFudd();        break;
  89.         case kWAREZ:    ConvertWAREZ();        break;
  90.         case kUbby:        ConvertUbby();        break;
  91.         case kOlde:        ConvertOlde();        break;
  92.         case kPig:        ConvertPig();        break;
  93.         case kMorse:    ConvertMorse();        break;
  94.         case kOp:        ConvertOp();        break;
  95.         case kRot13:    ConvertRot13();        break;
  96.     }
  97. }
  98.  
  99. void SetupSuffix(void)
  100. {
  101.     switch (gWhichDialect)
  102.     {
  103.         case kChef:
  104.             if (outputFS.name[0]>26)
  105.                 outputFS.name[0]=26;
  106.             outputFS.name[++(outputFS.name[0])]='.';
  107.             outputFS.name[++(outputFS.name[0])]='b';
  108.             outputFS.name[++(outputFS.name[0])]='o';
  109.             outputFS.name[++(outputFS.name[0])]='r';
  110.             outputFS.name[++(outputFS.name[0])]='k';
  111.             break;
  112.         case kFudd:
  113.             if (outputFS.name[0]>26)
  114.                 outputFS.name[0]=26;
  115.             outputFS.name[++(outputFS.name[0])]='.';
  116.             outputFS.name[++(outputFS.name[0])]='f';
  117.             outputFS.name[++(outputFS.name[0])]='u';
  118.             outputFS.name[++(outputFS.name[0])]='d';
  119.             outputFS.name[++(outputFS.name[0])]='d';
  120.             break;
  121.         case kWAREZ:
  122.             if (outputFS.name[0]>26)
  123.                 outputFS.name[0]=26;
  124.             outputFS.name[++(outputFS.name[0])]='.';
  125.             outputFS.name[++(outputFS.name[0])]='K';
  126.             outputFS.name[++(outputFS.name[0])]='0';
  127.             outputFS.name[++(outputFS.name[0])]='0';
  128.             outputFS.name[++(outputFS.name[0])]='L';
  129.             break;
  130.         case kUbby:
  131.             if (outputFS.name[0]>26)
  132.                 outputFS.name[0]=26;
  133.             outputFS.name[++(outputFS.name[0])]='.';
  134.             outputFS.name[++(outputFS.name[0])]='u';
  135.             outputFS.name[++(outputFS.name[0])]='b';
  136.             outputFS.name[++(outputFS.name[0])]='b';
  137.             outputFS.name[++(outputFS.name[0])]='y';
  138.             break;
  139.         case kOlde:
  140.             if (outputFS.name[0]>26)
  141.                 outputFS.name[0]=26;
  142.             outputFS.name[++(outputFS.name[0])]='.';
  143.             outputFS.name[++(outputFS.name[0])]='O';
  144.             outputFS.name[++(outputFS.name[0])]='l';
  145.             outputFS.name[++(outputFS.name[0])]='d';
  146.             outputFS.name[++(outputFS.name[0])]='e';
  147.             break;
  148.         case kPig:
  149.             if (outputFS.name[0]>25)
  150.                 outputFS.name[0]=25;
  151.             outputFS.name[++(outputFS.name[0])]='.';
  152.             outputFS.name[++(outputFS.name[0])]='i';
  153.             outputFS.name[++(outputFS.name[0])]='g';
  154.             outputFS.name[++(outputFS.name[0])]='p';
  155.             outputFS.name[++(outputFS.name[0])]='a';
  156.             outputFS.name[++(outputFS.name[0])]='y';
  157.             break;
  158.         case kMorse:
  159.             if (outputFS.name[0]>25)
  160.                 outputFS.name[0]=25;
  161.             outputFS.name[++(outputFS.name[0])]='.';
  162.             outputFS.name[++(outputFS.name[0])]='m';
  163.             outputFS.name[++(outputFS.name[0])]='o';
  164.             outputFS.name[++(outputFS.name[0])]='r';
  165.             outputFS.name[++(outputFS.name[0])]='s';
  166.             outputFS.name[++(outputFS.name[0])]='e';
  167.             break;
  168.         case kOp:
  169.             if (outputFS.name[0]>28)
  170.                 outputFS.name[0]=28;
  171.             outputFS.name[++(outputFS.name[0])]='.';
  172.             outputFS.name[++(outputFS.name[0])]='o';
  173.             outputFS.name[++(outputFS.name[0])]='p';
  174.             break;
  175.         case kRot13:
  176.             if (outputFS.name[0]>25)
  177.                 outputFS.name[0]=25;
  178.             outputFS.name[++(outputFS.name[0])]='.';
  179.             outputFS.name[++(outputFS.name[0])]='r';
  180.             outputFS.name[++(outputFS.name[0])]='o';
  181.             outputFS.name[++(outputFS.name[0])]='t';
  182.             outputFS.name[++(outputFS.name[0])]='1';
  183.             outputFS.name[++(outputFS.name[0])]='3';
  184.             break;
  185.     }
  186. }
  187.  
  188. void SetSuffixMenuItem(MenuHandle theMenu, int theItem)
  189. {
  190.     switch (gWhichDialect)
  191.     {
  192.         case kChef:
  193.             SetItem(theMenu, theItem, "\pAdd “.bork” suffix");
  194.             break;
  195.         case kFudd:
  196.             SetItem(theMenu, theItem, "\pAdd “.fudd” suffix");
  197.             break;
  198.         case kWAREZ:
  199.             SetItem(theMenu, theItem, "\pAdd “.K00L” suffix");
  200.             break;
  201.         case kUbby:
  202.             SetItem(theMenu, theItem, "\pAdd “.ubby” suffix");
  203.             break;
  204.         case kOlde:
  205.             SetItem(theMenu, theItem, "\pAdd “.Olde” suffix");
  206.             break;
  207.         case kPig:
  208.             SetItem(theMenu, theItem, "\pAdd “.igpay” suffix");
  209.             break;
  210.         case kMorse:
  211.             SetItem(theMenu, theItem, "\pAdd “.morse” suffix");
  212.             break;
  213.         case kOp:
  214.             SetItem(theMenu, theItem, "\pAdd “.op” suffix");
  215.             break;
  216.         case kRot13:
  217.             SetItem(theMenu, theItem, "\pAdd “.rot13” suffix");
  218.             break;
  219.     }
  220. }
  221.